#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
struct stu{
	char name[30];
    int age;
};
int cmpt(const void* p1, const void* p2) {
	return (*(struct stu*)p1).age -( *(struct stu*)p2).age;
}
void print(struct stu arr[], int sz) {
	int i = 0;
	for (i = 0; i < sz; i++) {
		printf("%s %d\n", arr[i].name, arr[i].age);
	}
}
void test() {
	struct stu arr[] = { {"zhangsan",30},{"lisi",22} ,{ "aiai",18 } };
	int sz = sizeof(arr) / sizeof(arr[0]);
	qsort(arr, sz, sizeof(arr[0]), cmpt);
	print(arr,sz);
}
int main() {
	test();
	return 0;
}